home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 4 / FM Towns Free Software Collection 4 - Disc 1.iso / toda / src / vedit.c < prev    next >
Text File  |  1991-10-18  |  18KB  |  748 lines

  1. /*
  2.             MOV SOUND DATA SAVE
  3.  
  4.             Hiroshi TODA
  5.             1991 7/28
  6. */
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <egb.h>
  11. #include <mos.h>
  12. #include <snd.h>
  13. #include "video.h"
  14.  
  15. /*#define C_WT 0x7fff*/        /* カーソル color */
  16. /*#define C_PL 24311*/        /* 初期プレーン color */
  17. /*#define C_FL 0x303030*/        /* files back color */
  18.  
  19. #define C_COLOR 15        /* Command color palette */
  20. #define W_COLOR 8        /* Window color palette */
  21. #define B_COLOR 7        /* Back color palette */
  22. #define E_COLOR 10        /* ERROR color palette */
  23. #define OK_COLOR 12        /* OK color palette */
  24.  
  25. extern int windget();
  26. extern int gprint( char *, int x, int y );
  27. extern int gprint2( char *, int x, int y );
  28. extern int mouse( int mpara[], int, int, int );
  29. extern int windput();
  30. extern int error_check( int );
  31. extern int look_files( char *path, char *fullname );
  32. extern int itochar( int var, int n, char *dsp );
  33.  
  34. extern int sw,cx,cy;    /* MOUSE data */
  35.  
  36. extern int mpara[];        /* mouse para */
  37. extern char para[];        /* PARAM */
  38. extern char gwork[];    /* graph work */
  39. extern char ework[];    /* EGB work */
  40. extern char bbuf[];    /* BACK-UP buf. */
  41.  
  42. /* mov sound save */
  43.  
  44. mov_sound_save( namemov )
  45. char namemov[];
  46. {
  47.     FILE *fp;
  48.     FILE *fps;
  49.     char head[256];
  50.     char path[100];        /* path */
  51.     char fullname[80];    /* file name */
  52.     char name[13];
  53.     char fmbname[13], pmbname[13];
  54.     char pcmname[8][13];
  55.     int ch[14], data[14];
  56.     int temp,min,max,i,j,k,k1,k2,wt;
  57.     int point[][2] = {    {  48, 447 },
  58.                 { 192, 447 },
  59.                 { 336, 447 },
  60.                 { 480, 447 },
  61.                 {  48, 479 },
  62.                 { 192, 479 },
  63.                 { 336, 479 },
  64.                 { 480, 479 }
  65.              };
  66.     char dsp0[] = "<<SOUND DATA>>   WRITE                                                      EXIT";
  67.     char dsp1[] = "FMB <<        >> ch0=    ch1=    ch2=    ch3=    ch4=    ch5=                   ";
  68.     char dsp2[] = "PMB <<        >> ch64=   ch65=   ch66=   ch67=   ch68=   ch69=   ch70=   ch71=  ";
  69.     char dsp3[] = "PCM0<<        >>  PCM1<<        >>  PCM2<<        >>  PCM3<<        >>";
  70.     char dsp4[] = "PCM4<<        >>  PCM5<<        >>  PCM6<<        >>  PCM7<<        >>";
  71.  
  72.     windput();
  73.         /* MOV DATA head read */
  74.     if( ( fp = fopen( namemov, "rb" ) ) == NULL )return 1;
  75.     temp = fread( head, 1, 256, fp );
  76.     fclose( fp );
  77.     if( temp < 256 )return 58;
  78.     if( DWORD(head+0) != 0x32564f4d )return 58;
  79.     if( DWORD(head+4) != 16 )return 58;
  80.     if( DWORD(head+16) != 320 )return 58;
  81.     if( DWORD(head+20) != 240 )return 58;
  82.         /* CHANEL read */
  83.     for( i=0 ; i<6 ; i++ )ch[i] = BYTE( head + 48 + i );
  84.     for( i=0 ; i<8 ; i++ )ch[ 6 + i ] = BYTE( head + 64 + i );
  85.         /* パネル表示 */
  86. snd01:    EGB_displayPage(ework,1,3);        /* mode3が前側 */
  87.     EGB_writePage(ework,1);        /* mode3に書き込み */
  88.     EGB_clearScreen(ework);
  89.     EGB_writeMode(ework,0);
  90.     EGB_color(ework,0,W_COLOR);
  91.     EGB_color(ework,2,W_COLOR);
  92.     EGB_paintMode(ework,0x22);
  93.     EGB_writeMode(ework,0);
  94.     WORD(para+0) = 0;
  95.     WORD(para+2) = 336;
  96.     WORD(para+4) = 639;
  97.     WORD(para+6) = 479;
  98.     EGB_rectangle(ework,para);
  99.     EGB_color(ework,0,C_COLOR);
  100.     gprint( dsp0, 0, 351 );
  101.     gprint( dsp1, 0, 383 );
  102.     gprint( dsp2, 0, 415 );
  103.     gprint( dsp3, 0, 447 );
  104.     gprint( dsp4, 0, 479 );
  105.         /* FMB data name */
  106.     for( i=0 ; i<8 ; i++ ){
  107.         fmbname[i] = head[ 40 + i ];
  108.         if( fmbname[i] == (char)0 )break;
  109.     }
  110.     if( i ){
  111.         fmbname[i] = (char)0;
  112.         gprint( fmbname, 48, 383 );
  113.         DWORD( fmbname+i )='.'+0x100*'F'+0x10000*'M'+0x1000000*'B';
  114.         fmbname[i+4]=(char)0;
  115.     }
  116.         /* PMB data name */
  117.     for( i=0 ; i<8 ; i++ ){
  118.         pmbname[i] = head[ 56 + i ];
  119.         if( pmbname[i] == (char)0 )break;
  120.     }
  121.     if( i ){
  122.         pmbname[i] = (char)0;
  123.         gprint( pmbname, 48, 415 );
  124.         DWORD( pmbname+i )='.'+0x100*'P'+0x10000*'M'+0x1000000*'B';
  125.         pmbname[i+4]=(char)0;
  126.     }
  127.         /* PCM data name */
  128.     for( j=0 ; j<8 ; j++ ){
  129.         for( i=0 ; i<8 ; i++ ){
  130.             pcmname[j][i] = head[ 72 + 8*j + i ];
  131.             if( pcmname[j][i] == (char)0 )break;
  132.         }
  133.         if( i ){
  134.             pcmname[j][i] = (char)0;
  135.             gprint( *(pcmname+j), point[j][0], point[j][1] );
  136.             DWORD( *(pcmname+j)+i )
  137.             = '.' + 0x100*'S' + 0x10000*'N' + 0x1000000*'D';
  138.             pcmname[j][i+4]=(char)0;
  139.         }
  140.     }
  141.     for( i = 0 ; i < 14 ; i++ )data[i] = -1;
  142.     mov_sound_save_dsp( ch, data );
  143. snd02:    MOS_disp(1);
  144.     mouse(mpara,0,0,1);
  145.     if( cy < 335 )goto snd02;
  146.     if( cy < 351 ){
  147.         if( cx < 128 )goto snd02;
  148.         if( cx < 184 ){        /* write */
  149.             j = 10;
  150.             goto snd05;
  151.         }
  152.         if( cx < 600 )goto snd02;
  153.         if( cx < 640 ){        /* exit */
  154.             j = 11;
  155.             goto snd05;
  156.         }
  157.         goto snd02;
  158.     }
  159.     if( cy < 367 )goto snd02;
  160.     if( cy < 383 ){
  161.         if( cx < 132 ){        /* fmb file name */
  162.             j = 0;
  163.             goto snd03;
  164.         }
  165.         if( cx < 196 ){
  166.             i = 0; min = 0; max = 127;
  167.             goto snd07;
  168.         }
  169.         if( cx < 260 ){
  170.             i = 1; min = 0; max = 127;
  171.             goto snd07;
  172.         }
  173.         if( cx < 324 ){
  174.             i = 2; min = 0; max = 127;
  175.             goto snd07;
  176.         }
  177.         if( cx < 388 ){
  178.             i = 3; min = 0; max = 127;
  179.             goto snd07;
  180.         }
  181.         if( cx < 452 ){
  182.             i = 4; min = 0; max = 127;
  183.             goto snd07;
  184.         }
  185.         if( cx < 516 ){
  186.             i = 5; min = 0; max = 127;
  187.             goto snd07;
  188.         }
  189.         goto snd02;
  190.     }
  191.     if( cy < 399 )goto snd02;
  192.     if( cy < 415 ){
  193.         if( cx < 132 ){        /* fmb file name */
  194.             j = 1;
  195.             goto snd03;
  196.         }
  197.         if( cx < 196 ){
  198.             i = 6; min = 0; max = 31;
  199.             goto snd07;
  200.         }
  201.         if( cx < 260 ){
  202.             i = 7; min = 0; max = 31;
  203.             goto snd07;
  204.         }
  205.         if( cx < 324 ){
  206.             i = 8; min = 0; max = 31;
  207.             goto snd07;
  208.         }
  209.         if( cx < 388 ){
  210.             i = 9; min = 0; max = 31;
  211.             goto snd07;
  212.         }
  213.         if( cx < 452 ){
  214.             i = 10; min = 0; max = 31;
  215.             goto snd07;
  216.         }
  217.         if( cx < 516 ){
  218.             i = 11; min = 0; max = 31;
  219.             goto snd07;
  220.         }
  221.         if( cx < 580 ){
  222.             i = 12; min = 0; max = 31;
  223.             goto snd07;
  224.         }
  225.         if( cx < 640 ){
  226.             i = 13; min = 0; max = 31;
  227.             goto snd07;
  228.         }
  229.         goto snd02;
  230.     }
  231.     if( cy < 431 )goto snd02;
  232.     if( cy < 447 ){
  233.         if( cx < 136 ){        /* pcm file name */
  234.             j = 2;
  235.             goto snd03;
  236.         }
  237.         if( cx < 280 ){        /* pcm file name */
  238.             j = 3;
  239.             goto snd03;
  240.         }
  241.         if( cx < 424 ){        /* pcm file name */
  242.             j = 4;
  243.             goto snd03;
  244.         }
  245.         if( cx < 568 ){        /* pcm file name */
  246.             j = 5;
  247.             goto snd03;
  248.         }
  249.         goto snd02;
  250.     }
  251.     if( cy < 463 )goto snd02;
  252.     if( cy < 479 ){
  253.         if( cx < 136 ){        /* pcm file name */
  254.             j = 6;
  255.             goto snd03;
  256.         }
  257.         if( cx < 280 ){        /* pcm file name */
  258.             j = 7;
  259.             goto snd03;
  260.         }
  261.         if( cx < 424 ){        /* pcm file name */
  262.             j = 8;
  263.             goto snd03;
  264.         }
  265.         if( cx < 568 ){        /* pcm file name */
  266.             j = 9;
  267.             goto snd03;
  268.         }
  269.         goto snd02;
  270.     }
  271.     goto snd02;
  272. snd03:    mouse(mpara,0,0,0);
  273.     if( sw > 1 )goto snd02;
  274.     MOS_disp(0);
  275.     windput();
  276.     for( k=0 ; k<80 ; k++ ){
  277.         path[k] = namemov[k];
  278.         if( path[k] == (char)0 )break;
  279.     }
  280.     for( i=k ; i>=0 ; i-- ){            /* path name 抽出 */
  281.         if( path[i] == '\\' || path[i] == ':' ){
  282.             path[i+1] = '*';
  283.             path[i+2] = '.';
  284.             if(j == 0)DWORD( path+i+3 )='F'+0x100*'M'+0x10000*'B';
  285.             if(j == 1)DWORD( path+i+3 )='P'+0x100*'M'+0x10000*'B';
  286.             if(j >= 2)DWORD( path+i+3 )='S'+0x100*'N'+0x10000*'D';
  287.             break;
  288.         }
  289.     }
  290.     for( i=0 ; i<8 ; i++ )name[i]=(char)0;
  291.     if( look_files( path, fullname ) == 0 ){
  292.         k1 = -1;
  293.         for( i=0 ; i<80 ; i++ ){
  294.             if(fullname[i] == '\\' || fullname[i] == ':')k1 = i;
  295.             if(fullname[i] == (char)0 || fullname[i] == '.')break;
  296.         }
  297.         k = 0; k1++; k2 = i;
  298.         if( k2-k1 > 8 )goto snd04;
  299.         for( i=k1 ; i<k2 ; i++ )name[k++] = fullname[i];
  300.     }
  301. snd04:    if( j == 0 )for( i=0 ; i<8 ; i++ )head[40+i] = name[i];
  302.     if( j == 1 )for( i=0 ; i<8 ; i++ )head[56+i] = name[i];
  303.     if( j > 1 && j < 10 ){
  304.         k = j - 2;
  305.         for( i=0 ; i<8 ; i++ )head[72+8*k+i] = name[i];
  306.     }
  307.     goto snd01;
  308.  
  309. snd05:    mouse(mpara,0,0,0);
  310.     if( sw > 1 )goto snd02;
  311.     MOS_disp(0);
  312.     windput();
  313.     switch( j ){
  314.        case 10: for( i=0 ; i<6 ; i++ ){ /* write protect の場合6回必要 */ 
  315.             if(
  316.                 ( fps = fopen( namemov, "r+b" ) ) != NULL
  317.             )goto snd06;
  318.             }
  319.             return 2;
  320.          snd06: for( i=0 ; i<6 ; i++ )BYTE( head + 48 + i ) = ch[i];
  321.             for( i=0 ; i<8 ; i++ )BYTE( head + 64 + i ) = ch[ 6 + i ];
  322.             fseek( fps, 0, SEEK_SET );
  323.             fwrite( head, 1, 256, fps );
  324.             temp = ferror( fps );
  325.             fclose( fps );
  326.             if( temp ){
  327.             /*remove( namemov );*/        /* error */
  328.             return 2;
  329.             }
  330.             return
  331.             mov_sound_page_save(namemov,fmbname,pmbname,pcmname,ch);
  332.        case 11: return 0;
  333.     }
  334.     goto snd01;
  335.  
  336. snd07:    wt = 125000;
  337. snd08:    if( sw == 1 )ch[i] = ch[i] + 1;
  338.     if( sw == 2 )ch[i] = ch[i] - 1;
  339.     if( ch[i] < min )ch[i] = max;
  340.     if( ch[i] > max )ch[i] = min;
  341.     mov_sound_save_dsp( ch, data );
  342.     for( k = 0 ; k < wt ; k++ );
  343.     wt = 10000;
  344.     MOS_rdpos(&sw,&cx,&cy);
  345.     if( sw > 0 )goto snd08;
  346.     goto snd02;
  347. }
  348.  
  349. mov_sound_save_dsp(ch,data)
  350. int ch[], data[];
  351. {
  352.     int i, x, y;
  353.     int point[][3] = {    { 168,383,3 },
  354.                 { 232,383,3 },
  355.                 { 296,383,3 },
  356.                 { 360,383,3 },
  357.                 { 424,383,3 },
  358.                 { 488,383,3 },
  359.  
  360.                 { 176,415,2 },
  361.                 { 240,415,2 },
  362.                 { 304,415,2 },
  363.                 { 368,415,2 },
  364.                 { 432,415,2 },
  365.                 { 496,415,2 },
  366.                 { 560,415,2 },
  367.                 { 624,415,2 }
  368.               };
  369.     char dsp[10];
  370.  
  371.     for( i = 0 ; i < 14 ; i++ ){
  372.         if( data[i] != ch[i] ){
  373.             MOS_disp(0);
  374.             itochar( ch[i], point[i][2], dsp );
  375.             EGB_color(ework,0,C_COLOR);
  376.             x = point[i][0];  y = point[i][1];
  377.             gprint2( dsp, x, y );
  378.             data[i] = ch[i];
  379.         }
  380.     }
  381.     return 0;
  382. }
  383.  
  384. /* mov sound page save */
  385.  
  386. mov_sound_page_save( namemov, fmbname, pmbname, pcmname, ch )
  387. char namemov[], fmbname[], pmbname[], pcmname[][13];
  388. int ch[];
  389. {
  390.     FILE *fp;
  391.     FILE *fps;
  392.  
  393.     char head[256];        /* head */
  394.     char bank[8];
  395.     char path[100];
  396.     char p[80];
  397.     int var[16];
  398.     int data[16];
  399.     int page,n,total,size,top,temp,min,max,i,j,k,wt;
  400.     char dsp[10];
  401.     char dsp0[] = "<< Page =     >>  WRITE  NEXT-PAGE  DISPLAY                                 EXIT";
  402.     char dsp1[] = " FMB/PMB1 << switch=   ch=    note=     velo=     TEST >>    OFFSET(x=    y=   )";
  403.     char dsp2[] = " FMB/PMB2 << switch=   ch=    note=     velo=     TEST >>    WAIT=     LOOP=   ";
  404.     char dsp3[] = "      PCM << switch=   ch=    note=     velo=     TEST >>";
  405.  
  406.     windput();
  407.         /* fmb, pmb data load */
  408.     make_path_name( path, namemov, fmbname );
  409.     SND_fm_bank_load( path, bank );
  410.     make_path_name( path, namemov, pmbname );
  411.     SND_pcm_bank_load( path, bank );
  412.     SND_elevol_mute( 0x03 ) ;
  413.     for( i=0 ; i<6 ; i++ )SND_inst_change( i, ch[i] );
  414.     for( i=0 ; i<8 ; i++ )SND_inst_change( 64+i, ch[6+i] );
  415.         /* mov data load */
  416.     for( i=0 ; i<6 ; i++ ){ /* write protect の場合6回必要 */ 
  417.         if( ( fp = fopen( namemov, "r+b" ) ) != NULL )goto snd0A;
  418.     }
  419.     return 2;
  420. snd0A:    fseek( fp, 0, SEEK_SET );
  421.     if( fread( head, 1, 256, fp ) < 256 ){
  422.         fclose( fp );
  423.         return 58;
  424.     }
  425.     total = 256; n = 0; page = DWORD( head + 12 );
  426.         /* mov data display */
  427.     DWORD( p+0 ) = (unsigned int)bbuf;
  428.     DWORD( p+4 ) = (unsigned int)bbuf+0x40000;
  429.     DWORD( p+8 ) = 0;
  430.     DWORD( p+12) = 0;
  431. snd00:    if( fread( bbuf, 1, 32, fp ) < 32 ){
  432.         fclose( fp );
  433.         return 58;
  434.     }
  435.     top = total; total += 32; size = DWORD( bbuf + 4 );
  436.     if( fread( bbuf+32, 1, size, fp ) < size ){
  437.         fclose( fp );
  438.         return 58;
  439.     }
  440.     if( (unsigned int)size > 500000 ){
  441.         fclose( fp );
  442.         return 58;
  443.     }
  444.     total += size;
  445.     move32( p );
  446.     EGB_clearScreen(ework);    /* page1を消さないとパネル表示の時見える */
  447.     n++;
  448.         /* read data from page head */
  449.     for( i=0 ; i<12 ; i++ )var[i] = BYTE( bbuf+20+i );    /* sound */
  450.     for( i=0 ; i<4 ; i++ )var[12+i] = WORD( bbuf+8+2*i );    /* etc. */
  451.     if( var[15] & 0x8000 )var[15] = -1;
  452.         /* パネル表示 */
  453. snd01:    EGB_displayPage(ework,1,3);        /* mode3が前側 */
  454.     EGB_writePage(ework,1);        /* mode3に書き込み */
  455.     EGB_clearScreen(ework);
  456.     EGB_writeMode(ework,0);
  457.     EGB_color(ework,0,W_COLOR);
  458.     EGB_color(ework,2,W_COLOR);
  459.     EGB_paintMode(ework,0x22);
  460.     EGB_writeMode(ework,0);
  461.     WORD(para+0) = 0;
  462.     WORD(para+2) = 367;
  463.     WORD(para+4) = 639;
  464.     WORD(para+6) = 479;
  465.     EGB_rectangle(ework,para);
  466.     EGB_color(ework,0,C_COLOR);
  467.     gprint( dsp0, 0, 383 );
  468.     gprint( dsp1, 0, 415 );
  469.     gprint( dsp2, 0, 447 );
  470.     gprint( dsp3, 0, 479 );
  471.     itochar( n, 3, dsp );
  472.     gprint( dsp, 80, 383 );
  473.     for( i = 0 ; i < 16 ; i++ )data[i] = -2;
  474.     mov_sound_page_save_dsp( var, data );
  475.         /* command loop */
  476. snd02:    MOS_disp(1);
  477.     mouse(mpara,0,0,1);
  478.     if( cy < 367 )goto snd02;
  479.     if( cy < 383 ){
  480.         if( cx < 136 )goto snd02;
  481.         if( cx < 192 ){        /* write */
  482.             j = 0;
  483.             goto snd05;
  484.         }
  485.         if( cx < 280 ){        /* next page */
  486.             j = 1;
  487.             goto snd05;
  488.         }
  489.         if( cx < 352 ){        /* display */
  490.             j = 2;
  491.             goto snd05;
  492.         }
  493.         if( cx < 608 )goto snd02;
  494.         if( cx < 640 ){        /* exit */
  495.             j = 3;
  496.             goto snd05;
  497.         }
  498.         goto snd02;
  499.     }
  500.     if( cy < 399 )goto snd02;
  501.     if( cy < 415 ){
  502.         if( cx < 96 )goto snd02;
  503.         if( cx < 176 ){            /* fmb switch */
  504.             i = 0; min = 0; max = 1;
  505.             goto snd07;
  506.         }
  507.         if( cx < 232 ){
  508.             i = 1; min = 0; max = 71;
  509.             goto snd07;
  510.         }
  511.         if( cx < 312 ){
  512.             i = 2; min = 0; max = 127;
  513.             goto snd07;
  514.         }
  515.         if( cx < 392 ){
  516.             i = 3; min = 0; max = 127;
  517.             goto snd07;
  518.         }
  519.         if( cx < 440 ){        /* fmb sound test */
  520.             j = 0;
  521.             goto snd03;
  522.         }
  523.         if( cx < 540 )goto snd02;
  524.         if( cx < 588 ){        /* x */
  525.             i = 12; min = 0; max = 319;
  526.             goto snd07;
  527.         }
  528.         if( cx < 640 ){        /* y */
  529.             i = 13; min = 0; max = 239;
  530.             goto snd07;
  531.         }
  532.         goto snd02;
  533.     }
  534.     if( cy < 431 )goto snd02;
  535.     if( cy < 447 ){
  536.         if( cx < 96 )goto snd02;
  537.         if( cx < 176 ){            /* pmb switch */
  538.             i = 4; min = 0; max = 1;
  539.             goto snd07;
  540.         }
  541.         if( cx < 232 ){
  542.             i = 5; min = 0; max = 71;
  543.             goto snd07;
  544.         }
  545.         if( cx < 312 ){
  546.             i = 6; min = 0; max = 127;
  547.             goto snd07;
  548.         }
  549.         if( cx < 392 ){
  550.             i = 7; min = 0; max = 127;
  551.             goto snd07;
  552.         }
  553.         if( cx < 440 ){        /* pmb sound test */
  554.             j = 1;
  555.             goto snd03;
  556.         }
  557.         if( cx < 480 )goto snd02;
  558.         if( cx < 564 ){        /* wait */
  559.             i = 14; min = 0; max = 999;
  560.             goto snd07;
  561.         }
  562.         if( cx < 640 ){        /* loop */
  563.             i = 15; min = -1; max = 999;
  564.             goto snd07;
  565.         }
  566.         goto snd02;
  567.     }
  568.     if( cy < 453 )goto snd02;
  569.     if( cy < 479 ){
  570.         if( cx < 96 )goto snd02;
  571.         if( cx < 176 ){            /* pcm switch */
  572.             i = 8; min = 0; max = 2;
  573.             goto snd07;
  574.         }
  575.         if( cx < 232 ){
  576.             i = 9; min = 0; max = 7;
  577.             goto snd07;
  578.         }
  579.         if( cx < 312 ){
  580.             i = 10; min = 0; max = 127;
  581.             goto snd07;
  582.         }
  583.         if( cx < 392 ){
  584.             i = 11; min = 0; max = 127;
  585.             goto snd07;
  586.         }
  587.         if( cx < 440 ){        /* pcm sound test */
  588.             j = 2;
  589.             goto snd03;
  590.         }
  591.         goto snd02;
  592.     }
  593.     goto snd02;
  594. snd03:    if( sw > 1 )goto snd02;
  595.     switch( j ){
  596.         case 0:    SND_key_off( var[1] );
  597.             if( !var[0] )break;
  598.             SND_key_on( var[1], var[2], var[3] );
  599.             while( sw )MOS_rdpos(&sw,&cx,&cy);
  600.             SND_key_off( var[1] );
  601.             break;
  602.         case 1:    SND_key_off( var[5] );
  603.             if( !var[4] )break;
  604.             SND_key_on( var[5], var[6], var[7] );
  605.             while( sw )MOS_rdpos(&sw,&cx,&cy);
  606.             SND_key_off( var[5] );
  607.             break;
  608.         case 2:    mouse(mpara,0,0,0);
  609.             if( pcmname[var[9]][0] == (char)0 )break;
  610.             make_path_name( path, namemov, *(pcmname+var[9]) );
  611.             if(
  612.               ( fps = fopen( path, "rb" ) ) == NULL
  613.             ){
  614.                 error_check(1);
  615.                 goto snd01;
  616.             }
  617.             if( fread( bbuf+32, 1, 32, fps ) < 32 ){
  618.                 fclose( fps );
  619.                 error_check(1);
  620.                 goto snd01;
  621.             }
  622.             temp = DWORD( bbuf+32+12 );
  623.             if( temp > 0x40000-100 ){
  624.                 fclose( fps );
  625.                 error_check(7);
  626.                 goto snd01;
  627.             }
  628.             if( fread( bbuf+64, 1, temp, fps ) < temp ){
  629.                 fclose( fps );
  630.                 error_check(1);
  631.                 goto snd01;
  632.             }
  633.             fclose( fps );
  634.             if( SND_pcm_mode_set( 1 ) ){
  635.                 SND_pcm_sound_delete( -1 );
  636.                 SND_pcm_mode_set( 1 );
  637.             }
  638.             SND_pcm_play_stop( 71 );
  639.             if( !var[8] )break;
  640.             if( var[8] == 1 ){
  641.                 SND_pcm_play( 71, var[10], var[11], bbuf+32 );
  642.             }
  643.             else SND_pcm_play2( 71, var[10], var[11], bbuf+32 );
  644.             break;
  645.     }
  646.     goto snd02;
  647. snd05:    mouse(mpara,0,0,0);
  648.     if( sw > 1 )goto snd02;
  649.     MOS_disp(0);
  650.     windput();
  651.     switch( j ){
  652.         case 0:    for( i=0 ; i<12 ; i++ )BYTE( bbuf+20+i ) = var[i];
  653.             for( i=0 ; i<4 ; i++ )WORD( bbuf+8+2*i ) = var[12+i];
  654.             fseek( fp, top, SEEK_SET );
  655.             fwrite( bbuf, 1, 32, fp );
  656.             fseek( fp, total, SEEK_SET );
  657.             goto snd09;
  658.         case 1:    goto snd09;
  659.         case 2:    mouse(mpara,0,0,0);
  660.             break;
  661.         case 3:    goto snd10;
  662.     }
  663.     goto snd01;
  664.  
  665. snd07:    wt = 125000;
  666. snd08:    if( sw == 1 )var[i] = var[i] + 1;
  667.     if( sw == 2 )var[i] = var[i] - 1;
  668.     if( var[i] < min )var[i] = max;
  669.     if( var[i] > max )var[i] = min;
  670.     mov_sound_page_save_dsp( var, data );
  671.     for( k = 0 ; k < wt ; k++ );
  672.     wt = 10000;
  673.     MOS_rdpos(&sw,&cx,&cy);
  674.     if( sw > 0 )goto snd08;
  675.     goto snd02;
  676.  
  677. snd09:    if( n < page )goto snd00;
  678.     else goto snd0A;
  679. snd10:    fclose( fp );
  680.     return 0;
  681. }
  682.  
  683. mov_sound_page_save_dsp(var,data)
  684. int var[], data[];
  685. {
  686.     int i, x, y;
  687.     int point[][3] = {    { 160,415,1 },    /* sond1 */
  688.                 { 208,415,2 },
  689.                 { 280,415,3 },
  690.                 { 360,415,3 },
  691.  
  692.                 { 160,447,1 },    /* sound2 */
  693.                 { 208,447,2 },
  694.                 { 280,447,3 },
  695.                 { 360,447,3 },
  696.  
  697.                 { 160,479,1 },    /* pcm */
  698.                 { 208,479,2 },
  699.                 { 280,479,3 },
  700.                 { 360,479,3 },
  701.  
  702.                 { 560,415,3 },    /* offset */
  703.                 { 608,415,3 },
  704.                 { 528,447,3 },    /* wait */
  705.                 { 608,447,3 }    /* loop */
  706.               };
  707.     char dsp[10];
  708.  
  709.     for( i = 0 ; i < 16 ; i++ ){
  710.         if( data[i] != var[i] ){
  711.             MOS_disp(0);
  712.             itochar( var[i], point[i][2], dsp );
  713.             EGB_color(ework,0,C_COLOR);
  714.             x = point[i][0];  y = point[i][1];
  715.             if( (i == 15) && (var[i] < 0) ){
  716.                 gprint2( "END", x, y );
  717.             }
  718.             else {
  719.                 gprint2( dsp, x, y );
  720.             }
  721.             data[i] = var[i];
  722.         }
  723.     }
  724.     return 0;
  725. }
  726.  
  727. /* path = fullname(path) + name 合成 */
  728.  
  729. make_path_name( path, fulname, name )
  730. char path[], fulname[], name[];
  731. {
  732.     int i, k;
  733.  
  734.     for( k=0 ; k<80 ; k++ ){
  735.         path[k] = fulname[k];
  736.         if( path[k] == (char)0 )break;
  737.     }
  738.     for( i=k ; i>=0 ; i-- ){    /* path name 抽出 */
  739.         if( path[i] == '\\' || path[i] == ':' )break;
  740.     }
  741.     for( k=0 ; k<13 ; k++ ){
  742.         path[i+1+k] = name[k];
  743.         if( name[k] == (char)0 )break;
  744.     }
  745.     return 0;
  746. }
  747.  
  748.